#include "GraphicsManager.h"
#include <iostream>

using namespace gull::core;
using namespace std;

const GUIAPI* GraphicsManager::s_wrapperGUI = NULL;
API3D* GraphicsManager::s_wrapper3D = NULL;

GraphicsManager::GraphicsManager()
{
	s_wrapperGUI = APIFactory::getGUIAPI("glut");
	s_wrapper3D = APIFactory::getAPI3D("opengl");

#if DEBUG
	cout << "Graphics Manager Create" << endl;
#endif
	
}


GraphicsManager::~GraphicsManager()
{
	delete s_wrapperGUI;
#if DEBUG
	cout << "Graphics Manager Release" << endl;
#endif
	
}

void
GraphicsManager::refreshFrame()
{
	s_wrapper3D->refreshFrame();
}

gullNotification 
GraphicsManager::initGraphicsContext()
{
	if(!s_wrapper3D || !s_wrapperGUI)
		return GULL_ERROR;
	
	if(s_wrapperGUI)
	{
		s_wrapperGUI->initGUIAPI();
		s_wrapperGUI->displayMode(GULL_RGBA);
	}
	
	
	return GULL_OK;
}

void
GraphicsManager::reshapeFrame(int w, int h)
{
	s_wrapper3D->reshapeFrame(w,h);
}
